package org.jivesoftware.smackx.provider;

import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.packet.MUCOwner;
import org.jivesoftware.smackx.packet.MUCOwner.Destroy;
import org.jivesoftware.smackx.packet.MUCOwner.Item;
import org.xmlpull.v1.XmlPullParser;

public class MUCOwnerProvider
  implements IQProvider
{
  private MUCOwner.Destroy parseDestroy(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCOwner.Destroy localDestroy = new MUCOwner.Destroy();
    localDestroy.setJid(paramXmlPullParser.getAttributeValue("", "jid"));
    while (true)
    {
      int j;
      label71: 
      do
        while (true)
        {
          do
          {
            if (i != 0)
              return localDestroy;
            j = paramXmlPullParser.next();
            if (j != 2)
              break label71;
          }
          while (!(paramXmlPullParser.getName().equals("reason")));
          localDestroy.setReason(paramXmlPullParser.nextText());
        }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("destroy"))));
      i = 1;
    }
  }

  private MUCOwner.Item parseItem(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCOwner.Item localItem = new MUCOwner.Item(paramXmlPullParser.getAttributeValue("", "affiliation"));
    localItem.setNick(paramXmlPullParser.getAttributeValue("", "nick"));
    localItem.setRole(paramXmlPullParser.getAttributeValue("", "role"));
    localItem.setJid(paramXmlPullParser.getAttributeValue("", "jid"));
    while (true)
    {
      int j;
      label137: 
      do
        while (true)
        {
          do
          {
            if (i != 0)
              return localItem;
            j = paramXmlPullParser.next();
            if (j != 2)
              break label137;
            if (paramXmlPullParser.getName().equals("actor"))
              localItem.setActor(paramXmlPullParser.getAttributeValue("", "jid"));
          }
          while (!(paramXmlPullParser.getName().equals("reason")));
          localItem.setReason(paramXmlPullParser.nextText());
        }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("item"))));
      i = 1;
    }
  }

  public IQ parseIQ(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    MUCOwner localMUCOwner = new MUCOwner();
    int i = 0;
    while (true)
    {
      int j;
      label105: 
      do
        while (true)
        {
          while (true)
          {
            while (true)
            {
              if (i != 0)
                return localMUCOwner;
              j = paramXmlPullParser.next();
              if (j != 2)
                break label105;
              if (!(paramXmlPullParser.getName().equals("item")))
                break;
              localMUCOwner.addItem(parseItem(paramXmlPullParser));
            }
            if (!(paramXmlPullParser.getName().equals("destroy")))
              break;
            localMUCOwner.setDestroy(parseDestroy(paramXmlPullParser));
          }
          localMUCOwner.addExtension(PacketParserUtils.parsePacketExtension(paramXmlPullParser.getName(), paramXmlPullParser.getNamespace(), paramXmlPullParser));
        }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("query"))));
      i = 1;
    }
  }
}